import warnings
import functools

__all__ = ["deprecated", "unchanged", "disabled", "enabled"]

def deprecated(func):
    """ This is a decorator which can be used to mark functions
    as deprecated.  It will result in a warning being emitted
    when the function is used. """

    @functools.wraps(func)
    def new_func(*args, **kwargs):
        warnings.warn_explicit(
                "Call to deprecated function %(funcname)s." % {
                    'funcname' : func.__name__,
                    },
                category=DeprecationWarning,
                filename=func.func_code.co_filename,
                lineno=func.func_code.co_firstlineno + 1
                )
        return func(*args, **kwargs)
    return new_func

def unchanged(func):
    return func

def disabled(func):
    def empty_func(*args, **kwargs):
        pass
    return empty_func

enabled = unchanged
